//检查单词是否为句中其他单词的前缀 力扣1455题
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int isPrefixOfWord(char* sentence, char* searchWord) 
{
 int count=0,i=0,t=0,xx=0,yy=0;
 int len=strlen(searchWord);
 int len2=strlen(sentence);
    for(i=0;i<strlen(sentence);i++)
    {
        if(sentence[i]==' '||(i==strlen(sentence)-1))
        {
            if(count==0&&sentence[i]==' ')
            count=-1;//保证第一次t是从0开始的
            yy++;
            for(t=count+1,xx=0;t<i,xx<len;)
            {
                if(sentence[t]==searchWord[xx])
                {
                if(xx==len-1)
                    return yy;
                t++,xx++;
                }
                else 
                    break;  
            }

        }
            if(sentence[i]==' ')
            count=i;
    }
    return -1;
}
int main() {
     char* a1 = "this problem is an easy problem";
     char* a2 ="pro";
    char* sentence =a1;
    char* searchWord=a2;
    int ret = isPrefixOfWord(sentence,searchWord);
printf("%d \n",ret);
    return 0;
}